package UI.List
{
	import flash.display.*;
	import flash.text.*;
	
	import mx.core.UIComponent;
	
	public class UIListItem extends UIComponent
	{
		private const HIGHLIGHT_COLOR:uint = uint(0xfff000);
		private const DEFAULT_COLOR:uint = uint(0xffffff);
		private var _itemName:TextField;
		
		public function UIListItem(name:String)
		{
			super();		
			this._itemName=generateTextField(name);	
			addChild(this._itemName);
		}
		
		private function generateTextField(text:String):TextField
		{
			var tf:TextFormat = new TextFormat();
			tf.align = TextFormatAlign.CENTER;
			var field:TextField = new TextField();
			field.text = text;
			field.selectable=false;
			field.background=true;
			field.mouseEnabled=false;
			field.setTextFormat(tf);
			return field;
		}
		
		public function set hilight(val:Boolean):void
		{
			_itemName.backgroundColor= val?HIGHLIGHT_COLOR:DEFAULT_COLOR;
		}
		
		public function get hilighted():Boolean
		{
			return (_itemName.backgroundColor==HIGHLIGHT_COLOR)?true:false
		}
		
		public function get itemName():String
		{
			return _itemName.text;
		}
		
		public override function set width(w:Number):void
		{
			_itemName.width = w;
		}
		
		public override function set height(h:Number):void
		{
			_itemName.height = h;
		}
		
		public override function get width():Number
		{
			return _itemName.width;
		}
		
		public override function get height():Number
		{
			return _itemName.height;
		}
	}
}